package com.zhouzi.zhaoyang.util.print;

import android.util.Log;

import com.google.gson.Gson;
import com.zhouzi.zhaoyang.base.App;
import com.zhouzi.zhaoyang.bean.PushGetOrderBean;
import com.zhouzi.zhaoyang.config.SharedPreferencesFinal;
import com.zhouzi.zhaoyang.http.HttpConfig;
import com.zhouzi.zhaoyang.util.SPUtils;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import okhttp3.Call;

/**
 * @author Jasmine
 * @date 2019/12/25.
 * @description
 */
public class GetOrder {
    public static void print(String outTradeNo){

        Log.e( "GetOrder","token"+ SPUtils.Companion.getInstance().getValue(SharedPreferencesFinal.TOKEN,"").toString());

        OkHttpUtils.get()
                .url(HttpConfig.BASE_URL+HttpConfig.GET_ORDER)
                .addHeader("Access-Token", SPUtils.Companion.getInstance().getValue(SharedPreferencesFinal.TOKEN,"").toString())
                .addParams("outTradeNo",outTradeNo)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        Log.e("GetOrder","onError"+e.getMessage());
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.e("GetOrder","onResponse"+response);
                        Gson gson = new Gson();
                        PushGetOrderBean data = gson.fromJson(response, PushGetOrderBean.class);
                        if (data!= null && data.getResult() != null){
                            App.Companion.instance().pushOrder(data);
                        }
                    }
                });
    }


}
